package com.example.scenictourback.dto;

import com.example.scenictourback.entity.Payment;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

@Data
public class PaymentDTO {
    
    private Integer id;
    private Integer orderId;
    private BigDecimal amount;
    private Integer method; // 1-微信, 2-支付宝
    private Date payTime;
    
    // 静态方法，将实体对象转为DTO对象
    public static PaymentDTO fromEntity(Payment payment) {
        PaymentDTO dto = new PaymentDTO();
        dto.setId(payment.getId());
        dto.setOrderId(payment.getOrder().getId());
        dto.setAmount(payment.getAmount());
        dto.setMethod(payment.getMethod());
        dto.setPayTime(payment.getPayTime());
        return dto;
    }
    
    // 静态方法，将实体列表转为DTO列表
    public static List<PaymentDTO> fromEntities(List<Payment> payments) {
        return payments.stream()
                .map(PaymentDTO::fromEntity)
                .collect(Collectors.toList());
    }
} 